package com.longma.server.controller;

import com.longma.server.pojo.dto.LoginParamDTO;
import com.longma.server.pojo.UserResponseEntity;
import com.longma.server.service.impl.SysUserServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author HAIBO
 * @date 2021-04-28 14:42
 * @description 登录
 */


@RestController
@Validated
public class LoginController {

    @Autowired
    private SysUserServiceImpl userService;

    @ApiOperation(value = "用户登录")
    @PostMapping("/api/login")
    public UserResponseEntity<String> login(@Valid @RequestBody LoginParamDTO loginParamDTO){
        return UserResponseEntity.success(userService.login(loginParamDTO));
    }

    @ApiOperation(value = "获取websocket地址")
    @GetMapping("/api/websocket/url")
    public UserResponseEntity<String> getWebSocketUrl(){
        return UserResponseEntity.success(userService.getWebSocketUrl());
    }
}
